import { _decorator, Component, Node, TiledMap, resources, Prefab, instantiate, Camera, v2, Canvas, director } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('map')
export class map extends Component {
    maincamrea = Camera
    map:TiledMap
    @property(Prefab)
	bulletPre:Prefab = null
    player:Node = null
    start() {
        this.map = this.node.getComponent(TiledMap)
        //普通层
        this.map.getLayers()
        //对象层
        let plater = this.map.getObjectGroup('st')
        let playerObject = plater.getObject('player')
        if(playerObject.isplayer===true){
            
                this.player = instantiate(this.bulletPre)
                // this.player.setParent(this.node.children[2].children[0])
                this.player.setParent(director.getScene().getChildByName('Canvas'))
                // console.debug(playerObject.x,
                //     playerObject.y,'xxx')
                this.player.setPosition(
                    playerObject.x,
                    playerObject.y
                )
        }
    }

    update(deltaTime: number) {
        if(this.player!==null){
            return this.player.getPosition()
        }
        
    }
}

